package com.exchange.controller.app.article;

import com.exchange.common.model.Article;
import com.jfinal.kit.Ret;
import com.jfinal.plugin.activerecord.Page;

public class ArticleService {
	
	int pageSize = 20;
	
	public Ret articleList(Integer type, Integer pageNumber){
		Page<Article> articleList = Article.dao.paginateByCache("articleList", type, pageNumber, pageSize, "SELECT id,caption,pubTime ", "FROM t_article WHERE type = ? AND state = 1 ORDER BY id ", type);
		return Ret.ok("articleList", articleList);
    }
	
	public Ret detail(Integer id){
		Article article = Article.dao.findFirstByCache("article", id, "SELECT * FROM t_article WHERE id = ? AND state = 1 ORDER BY id ", id);
		return Ret.ok("article", article);
    }
	
}
